package com.ruoyi.web.controller.api.user;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.WxQrCode;
import com.ruoyi.system.domain.PUserBill;
import com.ruoyi.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 用户-api
 * @Author: wk
 * @Date: 2022/7/20 16:57
 * @Version: 1.0
 */

@Validated
@Api(value = "用户-api", tags = {"前端-用户-api"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/user")
public class UserApiController extends BaseController {
    private final ISysUserService userService;

    @ApiOperation("生成推广人二维码")
    @PostMapping("/spread-banner")
    public R<String> importData() {
        return R.ok(WxQrCode.getAppId());
    }


    @ApiOperation("咨询师端我的")
    @GetMapping("/adviserInfo")
    public R<SysUser> adviserInfo() {
        return R.ok(this.userService.adviserInfo());
    }

    @ApiOperation("档期设置")
    @GetMapping("/scheduleConfig")
    public R<SysUser> scheduleConfig() {
        return R.ok(this.userService.scheduleConfig());
    }

    @ApiOperation("修改在线状态")
    @GetMapping("/onlineState")
    public R<Void> onlineState(@RequestParam("welfareSwitch") String welfareSwitch, @RequestParam("isOnline") Boolean isOnline) {
        this.userService.onlineState(welfareSwitch, isOnline);
        return R.ok();
    }

    @ApiOperation("积分商城获取我的积分")
    @GetMapping("/integralMy")
    public R<SysUser> integralMy() {
        return R.ok(this.userService.selectUserById(LoginHelper.getUserId()));
    }

    @ApiOperation("商城积分明细")
    @GetMapping("/integralDetail")
    public TableDataInfo<PUserBill> integralDetail(PageQuery pageQuery) {
        return this.userService.integralDetail(pageQuery);
    }

    @ApiOperation("每日签到")
    @GetMapping("/dailyCheck")
    public R<Void> dailyCheck() {
        this.userService.dailyCheck();
        return R.ok();
    }
}
